Assignemnt #77 and 75th program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: 75th Program
///File name: Sev5Prog.java
///Date Finished:12/16/2015
import java.util.Scanner;
import java.util.Random;
public class Sev5Prog
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int nextroom = 1;
String choice = "";
while ( nextroom != 0 )
{
if ( nextroom == 1 )
{
System.out.println( "You are in a very small room. There is a \"door\" to the north and a \"window\" to the south." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("window") )
nextroom = 2;
else if ( choice.equals("door") )
nextroom = 3;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 2 )
{
System.out.println( "You look out the window. The sun is rising over the mountains. There's nothing to do here except go \"back\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 3 )
{
System.out.println( "You go through the door and find yourself in a plain hallway. Oddly, there is only a single" );
System.out.println( "\"door\" visible. other than the doors, the hall has nothing to it, and it ends about fifteen feet in front of you." );
System.out.println( "Do you want to enter the \"door\" or go \"back\" to the room you came from?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("door") )
nextroom = 4;
else if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 4 )
{
System.out.println( "The door is now behind you. You look around and see you are in a field." );
System.out.println( "To the \"east\" are some horses, and to the \"west\" is a small town." );
System.out.println( "Which direction will you head?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("east") )
nextroom = 5;
else if ( choice.equals("west") )
nextroom = 6;
else if ( choice.equals("back"))
nextroom = 3;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 6 )
{
System.out.println( "You attempt to make your way to the town. However, it appears that you don't have enough energy to get it." );
System.out.println( "It seems that your only choice is to go \"back\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if (choice.equals("back"))
nextroom = 4;
else
System.out.print( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 5 )
{
System.out.println( "You made your way to the horses. They seem friendly. Will you try to ride a \"horse\", or go \"back\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if (choice.equals("back"))
nextroom = 4;
else if (choice.equals("horse"))
nextroom = 7;
else
System.out.print( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 7 )
{
System.out.println( "You jumped onto the horse and, before you could do anything, it takes off in the direction the town. " );
System.out.println( "After some time with the horse, you make it to the town. You hear people having normal conversations. " );
System.out.println( "You get off the horse and it runs back to the other horses. Do you want to \"explore\" the town?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if (choice.equals("back"))
nextroom = 8;
else if (choice.equals("explore"))
nextroom = 9;
else
System.out.print( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 8 )
{
System.out.println( "You try to go back but it's too far. You decide to stay in the town. You should \"explore\" the town." );
System.out.print( "> " );
choice = keyboard.nextLine();
if (choice.equals("explore"))
nextroom = 9;
else
System.out.print( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 9 )
{
System.out.println( "You look around town. You find two locations where you might be find answers to what's going on." );
System.out.println( "Do you check out the \"tavern\" or the \"police station\"?" );
choice = keyboard.nextLine();
if (choice.equals("tavern"))
nextroom = 10;
else if (choice.equals("police station"))
nextroom = 11;
else
System.out.print( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 10 )
{
System.out.println( "You enter the tavern. A Bar fight is going on. You try to leave, but a glass mug comes out of nowhere and knocks you out!" );
System.out.println( "GAME OVER!" );
nextroom = 0;
}
if( nextroom == 11 )
{
System.out.println( "You go to the police station and as soon as you start asking questions, They arrest you." );
System.out.println( "You have a sentence of twenty years in prison." );
System.out.println( "GAME OVER!" );
nextroom = 0;
}
}
}
}
Picture of the output